package com.itheima.reggie.mapper;

import com.itheima.reggie.entity.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Author: Rodgers
 * @Date 2022/3/10 9:30
 */
public interface CategoryMapper {

    //新增分类
    @Insert("insert into category values(null,#{type},#{name},#{sort},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    Long save(Category category);

    //查类名
    @Select("select * from category where name=#{name}")
    Category findByName(String name);

    //显示所有
    @Select("select * from category order by sort asc")
    List<Category> findAll();

    //删除
    @Delete("delete from category where category_id=#{categoryId}")
    Integer delete(Long categoryId);

    //通过id查找,回显
    @Select("select * from category where id=#{id}")
    Category findById(Long id);

    //修改
    Long update(Category category);

    //通过类型查找
    List<Category> findByType(@Param("type") Integer type);

}
